<template>
  <div>
    <!-- 返回按钮 -->
    <div>
      <el-button type="info" @click="router.push('/crud/footballteam')"
        >返回</el-button
      >
    </div>

    <!-- 球队简介呈现部分 -->
    <div v-loading="loading">
      <el-card v-if="footballteam.tname">
        <!-- 球队名字 -->
        <template #header>
          <div class="card-header">
            <span>{{ footballteam.tname }}</span>
          </div>
        </template>
        <!-- 球队简介 -->
        <div>
          <div v-html="footballteam.intro"></div>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { api } from '../../js/ajax'
import { tools } from '../../js/tools'
import { ElMessageBox, ElMessage } from 'element-plus'

const router = useRouter()
const route = useRoute()
const loading = ref(false)

const ftid = ref(route.query.ftid)

const footballteam = ref({})

const query = () => {
  loading.value = true
  api.get(`/crud/footballteam/${ftid.value}`, {}, data => {
    loading.value = false
    if (data.success) {
      footballteam.value = data.data
      return
    }
    ElMessageBox.alert(data.message, '足球队管理').finally(() => {
      router.push('/crud/footballteam')
    })
  })
}
query()
</script>

<style scoped>
/* 卡片样式 */
.el-card {
  width: 80%;
  margin: 1rem auto;
}

/* 卡片标题样式 */
.card-header {
  font-size: 1.5rem;
}
</style>
